home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "defs.h"
-
- #define BOLD_ON "\033[7m"
- #define BOLD_OFF "\033[m"
-
- har *progname;
- har *filename;
- ixrect *pr1, *pr2;
-
- #ifdef STANDALONE
- ain(argc, argv, envp)
- #else
- asval_main(argc, argv, envp)
- #endif
- int argc;
- char **argv;
- char **envp;
- {
- register int i, j;
- int noheaders, xoffset, yoffset, xsize, ysize;
- colormap_t colormap;
-
- noheaders = xsize = ysize = xoffset = yoffset = 0;
- progname = strsave(argv[0]);
- parse_profile(&argc, argv, envp);
-
- while ((gc = getopt(argc, argv, "nx:y:X:Y:")) != EOF)
- switch (gc) {
- case 'x':
- xoffset = atoi(optarg);
- break;
- case 'y':
- yoffset = atoi(optarg);
- break;
- case 'X':
- xsize = atoi(optarg);
- break;
- case 'Y':
- ysize = atoi(optarg);
- break;
- case 'n':
- noheaders++;
- break;
- case '?':
- errflag++;
- break;
- }
-
- if (errflag)
- error((char *) 0, "Usage: %s: [-n] [-x xoffset] [-y yoffset] [-X xsize] [-Y Ysize] [infile]\n", progname);
-
- for (stream = 0; optind < argc; stream++, optind++)
- if (stream == 0 && strcmp(argv[optind], "-") != 0)
- if (freopen(argv[optind], mode[stream], f[stream]) == NULL)
- error("%s %s", PR_IO_ERR_INFILE, argv[optind]);
-
- if ((pr1 = pr_load(stdin, &colormap)) == NULL)
- error(PR_IO_ERR_RASREAD);
-
- if (xsize == 0)
- xsize = 10;
- if (ysize == 0)
- ysize = 10;
-
- if ((pr2 = pr_region(pr1, xoffset, yoffset, xsize, ysize)) == NULL)
- error("pr_region returned NULL");
-
- if (!noheaders) {
- printf(" %s", BOLD_ON);
- for (i = 0; i < pr2->pr_size.x; i++)
- printf("%6d", xoffset + i);
- putchar('\n');
- }
- for (j = 0; j < pr2->pr_size.y; j++) {
- if (!noheaders)
- printf("%s%7d%s", BOLD_ON, yoffset + j, BOLD_OFF);
- for (i = 0; i < pr2->pr_size.x; i++)
- printf("%6d", pr_get(pr2, i, j));
- putchar('\n');
- }
- }
-